#include "widget.h"
#include "ui_widget.h"
#include <QHBoxLayout>
#include <QPushButton>
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    //构造布局管理器-水平
    QHBoxLayout *layout=new QHBoxLayout();
    //添加到窗口
    this->setLayout(layout);
    //设置按钮
    QPushButton *button1=new QPushButton("按钮1");
    QPushButton *button2=new QPushButton("按钮2");

    //创建Spacer空白控件
    //QSpacerItem *spacer=new QSpacerItem(宽度,高度);
    QSpacerItem *spacer=new QSpacerItem(100,100);
    //添加控件到水平布局管理器中-  按钮1 空白 按钮2
    layout->addWidget(button1);
    layout->addSpacerItem(spacer);
    layout->addWidget(button2);

}

Widget::~Widget()
{
    delete ui;
}

